﻿using System;


namespace WebCrawler
{
	/// <summary>
	/// Журнал
	/// </summary>
	static class Log
	{
		/// <summary>
		/// Запись сообщения в журнал
		/// </summary>
		/// <param name="message">текст сообщения</param>
		public static void Write(string message)
		{
			System.IO.StreamWriter log = System.IO.File.AppendText("crawler.log");

			log.Write("\r\nLog Entry : ");
			log.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(),
				DateTime.Now.ToLongDateString());
			log.WriteLine("  :");
			log.WriteLine("  :{0}", message);
			log.WriteLine("-------------------------------");
			log.WriteLine(string.Empty);
			log.Flush();
			log.Close();
		}

		/// <summary>
		/// Запись исключения в журнал
		/// </summary>
		/// <param name="message">исключение</param>
		public static void Write(Exception exception)
		{
			Write(exception.Message + Environment.NewLine + Environment.NewLine +
				exception.StackTrace
				);
		}
	}
}
